INSTRUCTION MANUAL nX-4/250/300 Core CMOS 4-BIT MICROCONTROLLER FIRST EDITION ISSUE DATE: Jun., 1997 nX-4/250/300 Core Instruction Manual Table of contents Table of Contents Introduction Chapter 1 - Architecture 1. OVERVIEW ....................................................................................................................1-1 2. CPU RESOURCES AND PROGRAMMING MODEL .....................................................1-1 2.1 Registers ....................................................................................................................1-3 2.1.1 Accumulator (A) ..................................................................................................1-4 2.1.2 Flag register .......................................................................................................1-4 2.1.2.1 Carry flag (C) ............................................................................................1-4 2.1.2.2 Zero flag (Z) ..............................................................................................1-4 2.1.2.3 G flag (G) ..................................................................................................1-4 2.1.3 Master interrupt enable flag (MIE) ......................................................................1-5 2.1.4 H register, L register, X register, Y register ........................................................1-5 2.1.5 Current bank register (CBR), extra bank register (EBR) ..................................... 1-6 2.1.6 RA register (RA3, RA2, RA1, RA0) ......................................................................1-7 2.1.7 Program counter (PC) .........................................................................................1-7 2.1.8 Stack pointer (SP, SPH/SPL) .............................................................................1-8 2.1.9 Register stack pointer (RSP) ..............................................................................1-9 2.2 Memory spaces .......................................................................................................1-10 2.2.1 Program memory space ...................................................................................1-10 2.2.2 Data memory space .........................................................................................1-13 2.2.2.1 SFR space ..............................................................................................1-14 2.2.3 External memory space .................................................................................... 1-15 2.3 Addressing modes ...................................................................................................1-16 2.3.1 Register addressing modes .............................................................................1-16 2.3.1.1 Register direct addressing mode ........................................................... 1-16 2.3.1.2 Bit direct addressing mode .................................................................... 1-17 2.3.1.3 Immediate addressing mode .................................................................1-17 2.3.2 Data memory addressing modes .....................................................................1-18 2.3.2.1 Direct addressing mode ......................................................................... 1-19 2.3.2.2 SFR bank internal direct addressing mode ........................................... 1-19 2.3.2.3 Current bank internal direct addressing mode ...................................... 1-20 2.3.2.4 HL register indirect addressing mode .................................................... 1-20 2.3.2.5 XY register indirect addressing mode .................................................... 1-21 2.3.2.6 Extra bank HL indirect addressing mode .............................................. 1-21 2.3.2.7 Extra band XY indirect addressing mode .............................................. 1-22 2.3.2.8 HL register indirect addressing mode with post increment ...............................................................................1-22 2.3.2.9 XY register indirect addressing mode with post-increment ...............................................................................1-23 2.3.2.10 Extra bank HL register indirect addressing mode with post-increment ...............................................................................1-23 2.3.2.11 Extra bank XY register indirect addressing mode with post-increment ...............................................................................1-24 1 nX-4/250/300 Core Instruction Manual Table of contents 2.3.2.12 Bit direct addressing mode .................................................................... 1-24 2.3.2.13 Bit indirect addressing mode .................................................................1-25 2.3.3 Addressing modes for program memory ......................................................... 1-26 2.3.3.1 64K word direct addressing mode ......................................................... 1-26 2.3.3.2 4K word page addressing mode ............................................................1-27 2.3.3.3 RA register indirect addressing mode ...................................................1-27 2.3.3.4 PC relative addressing mode .................................................................1-28 2.3.3.5 PC based addressing mode .................................................................. 1-29 2.3.4 Addressing mode for external memory ............................................................1-29 2.3.4.1 RA register indirect addressing mode ...................................................1-29 2.3.4.2 Direct addressing mode ......................................................................... 1-30 Chapter 2 - Instruction set 1. OVERVIEW ....................................................................................................................2-1 2. OPERAND EXPRESSION ..............................................................................................2-3 3. LIST OF INSTRUCTIONS ..............................................................................................2-5 4. INSTRUCTION DESCRIPTIONS .................................................................................2-33 2 nX-4/250/300 Core Instruction Manual Introduction Introduction This manual describes the instruction set of the nX-4/250 core and nX-4/300 core, which is designed for use as the CPU core for the original OKI CMOS 4-bit microcontroller. This manual is designed on the basis of the nX-4/250 core and nX-4/300 core basic architecture. The basic architecture of these constitutes the most important functional specifications of the nX4/250 core and nX-4/300 core. Depending on the model you are using the actual supported memory capacity may be a subset of the basic architecture. Please refer to the individual user's manual for such information. The following manuals related to the product line-up built around the nX-4/250 core and nX-4/300 core are available. Please refer to them for additional information. n MSM63XXX User's Manual Hardware description n ASM63KN Cross-assembler User's Manual Description of assembler operation and language specifications n EASE63XXX User's Manual Emulator hardware description n SID63K Operation Manual Debugger command description This manual consists of two chapters. Chapter 1 discusses the nX-4/250 core and nX-4/300 core basic architecture, beginning with explanations of the major resources used by the program, such as registers and memory, and then discussing addressing modes. explains the functions of each instruction, covering instruction function, their detailed action, and the instruction codes. Instruction descriptions are arranged in alphabetical order to serve as a reference. Chapter 2 0-1 Chapter 1 ARCHITECTURE This chapter describes the basic architecture of the nX-4/250 core and nX-4/300 core. The basic architecture is the most significant functional specification of the nX-4/250 core and nX-4/300. All microcontrollers using this core will have the same function as the basic architecture, or a subset thereof. This chapter covers the objectives of this document and its composition. nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 1. OVERVIEW The nX-4/250 core and nX-4/300 core instruction set consist of 440/450 instructions. The memory spaces are divided into a 16-bit width program memory space, a 4-bit width data memory space, and external 8-bit width memory. The program counter save stack (call stack) for subroutine call or interruption and register save stack (register stack) are prepared separately from memory space. The nX-4/250 core is a downward version of the nX-4/300 core. The differences between them are shown below. Table 1-1 Differences between nX-4/250 Core and nX-4/300 Core Core nX-4/250 nX-4/300 MMOV instruction BMOV instruction FCLR FLAG instruction FSET FLAG instruction Not provided provided Not provided provided Not provided provided Not provided provided 2. CPU RESOURCES AND PROGRAMMING MODEL This section describes the configuration of the CPU resources used in programming, such as registers and memory, along with their roles. Figures 1-1 to 1-2 show the relationship between program memory space, external memory, data memory and registers. Figures 1-3 show the relationship between these memory spaces and stack registers. Program Memory External Memory 0FFFFH 0FFFFH Program Data or ROM Table Data or Melody Data PC Interrupt Area 0000H 16 Bits RA 0000H 8 Bits Fig. 1-1 Relationship between Program Memory, External Memory, and Registers 1-1 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture Data Memory 0FFFH BANK15 RAM 0F00H CBR CBR EBR EBR 2FFH BANK2 RAM 200H 1FFH BANK1 Display Register 100H 0FFH BANK0 SFR 000H 4 Bits H X H X L Y L Y Fig. 1-2 Relationship between Data Memory and Registers Call Stack 32 Levels SPH SPL 16 Bits Register Stack 16 Levels RSP 16 Bits Fig. 1-3 Relationship between Stacks and Registers 1-2 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.1 Registers The nX-4/250 core and nX-4/300 core adopt a processing method that uses primarily accumulators and registers. The register set uses the programming model, with data memory addresses stored in the HL register, XY register, current bank register (CBR), extra bank register (EBR), and external memory and program memory addresses in the RA register. In addition registers are provided to control program flow, flags and memory. Figures 1-4 show register configurations. 3 A Accumulator 15 0 G C Z Flag Registers 0 PC Program Counter 15 RA3 12 11 RA2 87 RA1 43 RA0 0 RA Registers 3 RSP Register Stack Pointer 4 SPH 3 SPL 0 0 Stack Pointer 3 CBR Current Bank Register 3 EBR Extra Bank Register MIE Master Interrupt Enable Flag 0 7 X XY Register 0 7 H HL Register 43 Y 0 43 L 0 Fig. 1-4 Register Configuration 1-3 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.1.1 Accumulator (A) Accumulator (A) is a critical register for arithmetic operations. The accumulator is initialized to zero at reset. In the event that accumulator contents must be saved when an interrupt is generated or at other times, the PUSH HL instruction is used to save the value to the register stack. The register is restored with the POP HL instruction. 3 2 1 0 Fig. 1-5 Accumulator (A) 2.1.2 Flag registers The flag register consists of three flags: the carry flag (C), the zero flag (Z) and the G flag (G). In the event that flag register contents must be saved when an interrupt is generated or at other times, the PUSH HL instruction is used to save the value to the register stack. The register is restored with the POP HL instruction. G C Z Fig. 1-6 Flag Registers 2.1.2.1 Carry flag (C) The carry flag (C) is a 1-bit flag, and is used to load the carry for an additional instruction or the borrow for a subtraction instruction. The carry flag is initialized to zero at reset. 2.1.2.2 Zero flag (Z) The zero flag (Z) is a 1-bit flag, and is set to "1" when the content of the accumulator (A) is set to "0H". It is cleared to "0" when the content of the accumulator (A) is set to any value other than "0H". The zero flag is initialized to zero at reset. 2.1.2.3 G flag (G) The G flag is a 1-bit flag. This flag is set to "1" when the HL register, XY register, or RA register overflows as a result of execution of an increment instruction and is cleared to "0" when an overflow does not occur. The HL register or XY register is incremented when an indirect addressing instruction with post increment is executed or when an increment instruction is executed for the HL register or XY register. The RA register is incremented when an increment instruction is executed. 1-4 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.1.3 Master interrupt enable flag (MIE) The master interrupt enable flag (MIE) is the flag used to control enable/disable for maskable interrupts. When set to "1" maskable interrupts are enabled, and when cleared to "0" maskable interrupts are disabled. If a maskable interrupt is received, the MIE flag is cleared to "0", and then restored to "1" through the execution of the maskable interrupt return instruction (RTI instruction). Instruction execution in the maskable interrupt processing routine can set to the MIE flag to "1" to make possible multilevel interrupt processing. MIE flag set and clear are implemented with the "EI" and "DI" instructions, which are only used for MIE flag operations. The MIE flag is initialized to zero at reset. The MIE flag is allocated to address 0FFH of the special function register (SFR). 2.1.4 H register, L register, X register, Y register The H register, L register, X register and Y register are used as working registers during program processing. The H and L registers are used as a register pair in the data memory indirect addressing mode, as are the X and Y registers. All four registers are initialized to zero at reset. In the event that register contents must be saved when an interrupt is generated or at other times, the PUSH HL or PUSH XY instruction is used to save the value to the register stack. The register is restored with the POP HL or POP XY instruction. The H, L, X and Y registers are allocated to addresses 0F9H through 0FCH of the special function register (SFR). 3 2 H 1 03 2 L 1 0 HL Register Pair H Register 3 2 X X Register 1 03 L Register 2 Y Y Register 1 0 XY Register Pair Fig. 1-7 H, L, X, and Y Registers 1-5 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.1.5 Current bank register (CBR), extra bank register (EBR) The current bank register (CBR) and extra bank register (EBR) are used for data memory space bank specification. CBR and EBR are initialized to zero at reset. In the event that register contents must be saved when an interrupt is generated or at other times, the PUSH XY instruction is used to save the value to the register stack. The register is restored with the POP XY instruction. The CBR and EBR are allocated to addresses 0FDH through 0FEH of the special function register (SFR). 3 2 CBR Current Bank Register (CBR) 3 2 EBR Extra Bank Register (EBR) Fig. 1-8 Current Bank Register and Extra Bank Register CBR and EBR are used in combination with the HL and XY registers for indirect addressing of data memory. CBR is used in combination with the 8-bit data in the instruction code for direct addressing within the current bank. Fig. 1-9 indicates the register combinations used. 1 0 1 0 CBR CBR EBR EBR CBR A11 ~ A8 + + + + + H X H X L Y L Y Instruction code 8-bit data A7 ~ A4 A3 ~ A0 Fig. 1-9 Register Combinations A11 to A0 indicate data memory (max. 4K nibbles ) address. 1-6 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.1.6 RA register (RA3, RA2, RA1, RA0) THe RA registers are used for program memory indirect addressing (ROM table reference instruction) and external memory indirect addressing (external memory transfer instruction). Fig. 1-10 indicates the address configuration for the RA registers. RA3 A15 ~ A12 RA2 A11 ~ A8 RA1 A7 ~ A4 RA0 A3 ~ A0 Fig. 1-10 Address Configuration for Registers RA3 through RA0 When used for ROM table reference instructions, A15 through A0 indicate a maximum of 64K bytes of program memory addresses. When used for external memory transfer instructions, A15 through A0 indicate a maximum of 64K bytes of external memory addresses. RA3 through RA0 are allocated to addresses 0F2H through 0F5H of the special function register (SFR). The RA registers are initialized to zero at reset. 2.1.7 Program counter (PC) The program counter (PC) is the counter used to store the address of the program code to be executed next. The PC bit length is 16 bits , which means it can specify an address within 64K byte program memory space. The PC is increased immediately after the program code is fetched from program memory, and this repetition creates program flow. For a branch instruction the new program code address is set to the PC. The PC is initialized to zero at reset. When an interrupt is generated the execution restart address is automatically saved to the call stack. This value can be restored to the PC through the RTI instruction. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Fig. 1-11 Program Counter 1-7 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.1.8 Stack pointer (SP or SPH/SPL) The stack pointer (SP or SPH/SPL) is a pointer indicating the head address of the call stack, which is used for saving program counters at subroutine calls and interrupt. The stack pointer is a 5-bit up/down counter , counting up at stack save and down at stack restore. The call stack is 16 bits wide, and uses one level for PC save. It has a maximum of 32 levels. The stack ponter is initialized to zero at reset, and points to address "00H" in the call stack. The SPH/SPL are allocated to address "0F8H" and "0F7H", respectively, of the special function register (SFR). The stack pointer is a read-only register, and write is disabled. Figs. 1-12 indicate the relation between the stack pointer (SP) and the call stack. Call Stack 0FH 43 SPH 2 SPL 1 0 32 Levels Stack Pointer 0H 16 Bits Fig. 1-12 Relation between SPH/SPL and Call Stack 1-8 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.1.9 Register stack pointer (RSP) The register stack pointer (RSP) is a pointer indicating the address of the register stack, used for saving various registers. The RSP is a 4-bit up/down counter, counting up at stack save (PUSH instruction) and down at a stack restore (POP instruction). The register stack is 16 bits wide, and uses one level for register save. It has a maximum of 16 levels. The RSP is initialized to zero at reset, and points to address "0H" in the call stack. The RSP is allocated to address "0F6H" of the special function register (SFR). Fig. 1-13 indicates the relation between the RSP and the register stack. Register Stack 0FH 3 2 1 RSP Register Stack Pointer 00H 16 Bits 0 16 Levels Fig. 1-13 Relation between RSP and Register Stack The PUSH/POP instructions can be used to save various registers to the register stack, and restore them, as shown in Fig. 1-14. PUSH HL and POP HL instruction execution 15 -- 14 G 13 C 12 Z 11 10 A Register Stack PUSH XY and POP XY instruction execution 15 14 13 12 11 10 9 8 7 6 X Register Stack 5 4 3 2 Y 1 0 9 8 7 6 H 5 4 3 2 L 1 0 EBR CBR Fig. 1-14 Save/restore registers at PUSH/POP Instruction Execution 1-9 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.2 Memory spaces The nX-4/250 core and nX-4/300 core memory spaces each consist of program memory space, data memory space and external memory space. This section discusses the structures of these memory spaces. Note that the program counter save stack (call stack) used at subroutine calls or interrupts, the address save stack (melody stack) for melody output and the register save stack (register stack) are separate from the memory space. 2.2.1 Program memory space Program memory has a 16-bit data length with a 64 word capacity. The program memory space stores ROM data and melody data in addition to program data. Figs. 1-15 indicate the program memory configurations. 0FFFFH Program Data or ROM Table Data or Melody Data 65536 Words 00FFH Interrupt Area 0001H 0000H 16 Bits Instruction Execution Start Address Fig. 1-15 Program Memory Configuration (nX-4/300) 255 Words 1 - 10 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture Address 0000H is the instruction execution start address when the system is reset. Allocated in 0001H through 00FFH are interrupt process routine start addresses when an interrupt occurs. See the user's manual for your device because the allocation is different depending on the type of device. ROM table data is transfered to data memory by a ROM table reference instruction. Melody data defines musical scale, tone length, and end tone used in a melody circuit. Melody data is automatically transfered to a melody circuit after its start address is indicated by a MSA instruction. Ths MSA instruction cannot be used for a device in which a melody circuit is not included. In the program memory space, 1 page consists of 4K words. The nX-4/250 core and nX-300 core has 16 pages. The LJMP and LCAL instructions can access the entire program memory space, but the JMP and CAL instructions can access only a page internal. The RA register indirect addressing instruction, PC relative addressing instruction, and PC based addressing instruction can access each page irrespective of the boundaries of pages 1 - 11 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 0FFFFH 0F000H 0EFFFH 0E000H 0DFFFH 0D000H 0CFFFH 0C000H 0BFFFH 0B000H 0AFFFH 0A000H 9FFFH 9000H 8FFFH 8000H 7FFFH 7000H 6FFFH 6000H 5FFFH 5000H 4FFFH 4000H 3FFFH 3000H 2FFFH 2000H 1FFFH 1000H 0FFFH 0000H Page 15 Page 14 Page 13 Page 12 Page 11 Page 10 Page 9 Page 8 Page 7 Page 6 Page 5 Page 4 Page 3 Page 2 Page 1 Page 0 JMP, CAL Space (4096 Words) LJMP, LCAL Space (65356 Words) Fig. 1-16 Pages in Program Memory Space (nX-4/300) 1 - 12 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.2.2 Data memory space Data memory space holds the data RAM and special function register (SFR). As indicated in Fig. 1-17 below, the data memory consists of 16 banks, with each bank unit having 256 nibbles in size. BANK0 is assigned to SFR space, and bank1 to 15 (3480 nibbles) are assigned to data RAM. 0FFFH 0F00H 0EFFH 0E00H 0DFFH 0D00H 0CFFH 0C00H 0BFFH BANK11 0B00H 0AFFH BANK10 0A00H 9FFH BANK9 900H 8FFH 800H 7FFH BANK7 700H 6FFH BANK6 600H 5FFH 500H 4FFH BANK4 400H 3FFH 300H 2FFH BANK2 200H 1FFH BANK1 100H 0FFH 000H 4 bits BANK0 SFR space (256 nibbles) 000H 4 bits Other SFR space BANK3 BANK5 BANK8 Data RAM space (3840 nibbles) 0FFH 0FEH 0FDH 0FCH 0FBH 0FAH 0F9H 0F8H 0F7H 0F6H 0F5H 0F4H 0F3H 0F2H 0F1H BANK15 BANK14 BANK13 BANK12 MIEF EBR CBR H L X Y SPH SP or SPL RSP RA3 RA2 RA1 RA0 Fig. 1-17 Data Memory Space Configuration 1 - 13 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.2.2.1 SFR space The 256-nibble SFR space from 000H to 0FFH contains the special function register (SFR) used to control peripheral functions connected to the CPU core. The 0F2H to 0FFH are allocated to CPU core registers as indicated in Table 1-2 below. Table 1-2 Register SFR Allocation Address 0F2H 0F3H 0F4H 0F5H 0F6H 0F7H 0F8H 0F9H 0FAH 0FBH 0FCH 0FDH 0FEH 0FFH (Note) RA0 register RA1 register RA2 register RA3 register Register stack pointer Stack pointer L Stack pointer H Y register X register L register H register Current bank register Extra bank register Master interrupt enable flag Register name symbol RA0 RA1 RA2 RA3 RSP SPL SPH Y X L H CBR EBR MIEF Content b3 a3 a7 a11 a15 rsp3 SP3 --* y3 x3 l3 h3 c3 e3 --* b2 a2 a6 a10 a14 rsp2 SP2 --* y2 x2 l2 h2 c2 e2 --* b1 a1 a5 a9 a13 rsp1 SP1 --* y1 x1 l1 h1 c1 e1 --* b0 a0 a4 a8 a12 rsp0 SP0 SP4 y0 x0 l0 h0 c0 e0 MIE R/W R/W R/W R/W R/W R/W R R R/W R/W R/W R/W R/W R/W R * = reserved bit : Always reads "1". Write is disabled. "R" indicates read-only and "R/W" indicates read and write are enabled. 1 - 14 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.2.3 External memory space The external memory space has an 8-bit data length data space, allocated from address 00000H to address 0FFFFH. The external memory space is configured as indicated in Fig. 1-18. 0FFFFH Data 65536 Bytes 0000H 8 Bits Fig. 1-18 External Memory Space Configuration 1 - 15 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.3 Addressing modes Addressing modes are classified as indicated in Table 1-3. Table 1-3 Addressing Mode Classification Classification Content Register direct Bit direct Immediate Register addressing modes Data memory addressing modes Direct SFR bank internal direct Current bank internal direct HL register indirect XY register indirect Extra bank HL register indirect Extra bank XY register indirect Post-incremented HL register indirect Post-incremented XY register indirect Post-incremented extra bank HL register indirect Post-incremented extra bank XY register indirect Bit direct Bit indirect Program memory addressing modes 64 K word direct 4K word page internal direct RA register indirect PC relative PC based External memory addressing modes RA register indirect Direct 2.3.1 Register addressing mode 2.3.1.1 Register direct addressing mode Instructions can be used to directly set the accumulator (A), HL register, XY register, RA3 to RA0 registers, current flag register (CFR), extra bank register (EBR) and flag register (FLAG). n Operand description * A, H, L, X, Y, CBR, EBR, FLAG * HL, XY, RA n Description example INCB HL ; Increment HL register 1 - 16 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.3.1.2 Bit direct addressing mode Instructions can be used to perform bit operations on the zero flag (Z), carry flag (C) and G flag of the flag register (FLAG). n Operand description * Z, C, G n Description example FCLR C ; Clear carry flag 2.3.1.3 Immediate addressing mode The numerical values in an instruction are directly treated as data. n Operand description * #i n Description example MOV CBR, #4H ; Write immediate data 4H to CBR 1 - 17 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.3.2 Data memory addressing modes The following data memory addressing modes are supported: Data memory addressing Direct addressing Direct addressing SFR bank internal direct addressing Current bank internal direct addressing Register indirect addressing HL register indirect addressing XY register indirect addressing Extra bank HL register indirect addressing Extra bank XY register indirect addressing Post-incremented HL register indirect addressing Post-incremented XY register indirect addressing Post-incremented extra bank HL register indirect addressing Post-incremented extra bank XY register indirect addressing The post-incremented indirect addressing mode can add +1 or +2 to the HL or XY register after instruction execution. * For +1 In the 4-bit unit operation mode, the HL register or XY register is incremented by one after instruction execution. If the HL or XY register overflows as a result (HL = 0 or XY = 0), the G flag is set to "1" . If there is no overflow, the G flag is cleared to "0". * For +2 In the 8-bit unit operation mode (ROM table reference instruction, external memory transfer instruction), the HL register or XY register is incremented by two after instruction execution. If the HL or XY register overflows as a result (HL > 0FFH or XY > 0FFH), the G flag is set to "1". If there is no overflow, the G flag is cleared to "0". [Note] The post-incremented indirect addressing mode should not be used for XY, HL, CBR, and EBR registers located in 0F9H to 0FEH of the SFR space. 1 - 18 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.3.2.1 Direct addressing mode The data memory space address is directly specified by the 12-bit address data in the instruction code. Address data a11 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 11 Data memory space address a11 10 a10 9 a9 8 a8 7 a7 6 a6 5 a5 4 a4 3 a3 2 a2 1 a1 0 a0 n Operand description * direct n Description example MOV 326H, A ; Transfers accumulator content to address 26H of bank 3 2.3.2.2 SFR bank internal direct addressing mode The data memory space SFR space (bank 0) is directly specified by the 8-bit address data in the instruction code. Address data a7 a6 a5 a4 a3 a2 a1 a0 11 Data memory space address 0 10 0 9 0 8 0 7 a7 6 a6 5 a5 4 a4 3 a3 2 a2 1 a1 0 a0 n Operand description * sfr n Description example MOV 36H, #0CH ; Write immediate data 0CH to address 36H of the SFR (bank0) 1 - 19 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.3.2.3 Current bank internal direct addressing mode The data memory space address is directly specified by the 8-bit address data in the current bank register (CBR). CBR c3 c2 c1 c0 a7 a6 a5 Address data a4 a3 a2 a1 a0 11 Data memory space address c3 10 c2 9 c1 8 c0 7 a7 6 a6 5 a5 4 a4 3 a3 2 a2 1 a1 0 a0 n Operand description * cur n Description example INC 32H ; Increments the content of address 32H in the bank indicated by CBR, and stores the result to address 32H and accumulator 2.3.2.4 HL register indirect addressing mode The data memory space address is indirectly specified by the current bank register (CBR) and the HL register. CBR c3 c2 c1 c0 h3 h2 H h1 h0 l3 l2 L l1 l0 11 Data memory space address c3 10 c2 9 c1 8 c0 7 h3 6 h2 5 h1 4 h0 3 l3 2 l2 1 l1 0 l0 n Operand description * [HL] or C:[HL] n Description example MOV [HL], A ; The accumulator content is transferred to the data memory specified by the CBR and HL registers 1 - 20 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.3.2.5 XY register indirect addressing mode The data memory space address is indirectly specified by the current bank register (CBR) and the XY register. CBR c3 c2 c1 c0 x3 x2 X x1 x0 y3 y2 Y y1 y0 11 Data memory space address c3 10 c2 9 c1 8 c0 7 x3 6 x2 5 x1 4 x0 3 y3 2 y2 1 y1 0 y0 n Operand description * [XY] or C:[XY] n Description example DEC [XY] ; The data memory content specified by the CBR and XY registers is decremented, and the result stored to the data memory and accumulator. 2.3.2.6 Extra bank HL indirect addressing mode The data memory space address is indirectly specified by the extra bank register (EBR) and the HL register. EBR e3 e2 e1 e0 h3 h2 H h1 h0 l3 l2 L l1 l0 11 Data memory space address e3 10 e2 9 e1 8 e0 7 h3 6 h2 5 h1 4 h0 3 l3 2 l2 1 l1 0 l0 n Operand description * E:[HL] n Description example ROR E:[HL] ; The data memory content specified by the EBR and HL registers is rotated right, including the carry, and the result stored to the data memory and accumulator. 1 - 21 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.3.2.7 Extra bank XY indirect addressing mode The data memory space address is indirectly specified by the extra bank register (EBR) and the XY register. EBR e3 e2 e1 e0 x3 x2 X x1 x0 y3 y2 Y y1 y0 11 Data memory space address e3 10 e2 9 e1 8 e0 7 x3 6 x2 5 x1 4 x0 3 y3 2 y2 1 y1 0 y0 n Operand description * E:[XY] n Description example AND E:[XY], A ; The logical product of the data memory content specified by the EBR and XY registers and the accumulator is stored to the data memory and accumulator. 2.3.2.8 HL register indirect addressing mode with post-increment The data memory space address is indirectly specified by the current bank register (CBR) and the HL register. After execution the HL register is incremented by +1 or +2. CBR c3 c2 c1 c0 h3 h2 H h1 h0 l3 l2 L l1 l0 11 Data memory space address c3 10 c2 9 c1 8 c0 7 h3 6 h2 5 h1 4 h0 3 l3 2 l2 1 l1 0 l0 n Operand description * [HL+] or C:[HL+] n Description example MOV [HL+], A ; The accumulator content is transferred to the data memory specified by the CBR and HL registers and then the HL register is incremented by one. 1 - 22 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.3.2.9 XY register indirect addressing mode with post-increment The data memory space address is indirectly specified by the current bank register (CBR) and the XY register. After execution the XY register is incremented by +1 or +2. CBR c3 c2 c1 c0 x3 x2 X x1 x0 y3 y2 Y y1 y0 11 Data memory space address c3 10 c2 9 c1 8 c0 7 x3 6 x2 5 x1 4 x0 3 y3 2 y2 1 y1 0 y0 n Operand description * [XY+] or C:[XY+] n Description example XOR [XY+], A ; The results of an exlusive-OR between accumulator and the data memory content specified by the CBR and XY registers are stored to the accumulator and data memory. Then the XY register is incremented by one. 2.3.2.10 Extra bank HL register indirect addressing mode with post-increment The data memory space address is indirectly specified by the extra bank register (EBR) and the HL register. After execution the HL register is incremented by +1 or +2. EBR e3 e2 e1 e0 h3 h2 H h1 h0 l3 l2 L l1 l0 11 Data memory space address e3 10 e2 9 e1 8 e0 7 h3 6 h2 5 h1 4 h0 3 l3 2 l2 1 l1 0 l0 n Operand description * E:[HL+] n Description example MOV E:[HL+], #00H ; Immediate data 00H is transferred to the accumulator and the data memory specified by the EBR and HL registers, then the HL register is incremented by one. 1 - 23 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.3.2.11 Extra bank XY register indirect addressing mode with post-increment The data memory space address is indirectly specified by the extra bank register (EBR) and the XY register. After execution the XY register is incremented by +1 or +2. EBR e3 e2 e1 e0 x3 x2 X x1 x0 y3 y2 Y y1 y0 11 Data memory space address e3 10 e2 9 e1 8 e0 7 x3 6 x2 5 x1 4 x0 3 y3 2 y2 1 y1 0 y0 n Operand description * E:[XY+] n Description example MOV E:[XY+], A ; The accumulator content is transferred to the data memory specified by the EBR and XY registers, then the XY register is incremented by one. 2.3.2.12 Bit direct addressing mode Executes data memory bit operations, which may be bit operations in 1-bit units (specified with ".n") or multi-bit operations (specified with "#m"). n Operand description * [HL].n, [XY].n, C:[HL].n, C:[XY].n, E:[HL].n, E:[XY].n, [HL+].n, [XY+].n, E:[HL+].n, E:[XY+].n, cur.n (n = 0 ~ 3, 0:LSB, 3:MSB) n Description example BCLR [XY].3 ; The third bit of the data memory specified by the CBR and XY register is cleared, and the result stored to the data memory and accumulator. n Operand description * #m n Description example MCLR [XY].#3H ; Bits 0 and 1 of the data memory specified by the CBR and XY register are cleared, and the result stored to the data memory and accumulator. 1 - 24 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.3.2.13 Bit indirect addressing mode Executes data memory bit operations. The operated bit is specified by the content of the accumulator (A). n Operand description * A n Description example MTST 35H, A ; When A=3H, bits 0,1 of address 35H of the SFR (bank 0) are tested, and if either or both is zero the Z flag is set. 1 - 25 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.3.3 Addressing modes for program memory 2.3.3.1 64K word direct addressing mode 16-bit address data are used to address the entire program memory space. n Operand description * cadr16 n Description example MOVLB [HL], 0FFEH ; The lower 8bits of program memory address 0FFEH are transferred to the data memory specified by CBR and HL registers, and to the next address in data memory. Program memory 3FFFH or 0FFFFH Data memory CBR CBR 15 0FFEH 12 11 87 43 0 + + H H L L +1 n Description example LJMP 0234H ; Branch to the program memory address specified by the 16-bit direct address 1 - 26 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.3.3.2 4K word page addressing mode 12-bit address data is used to address the program memory page. n Operand description * cadr12 n Description example JMP 123H ; Branch to the program memory address within that page, specified by the 12-bit address 2.3.3.3 RA register indirect addressing mode The program memory space address is indirectly specified with the 16-bit address data in the RA register. RA3 RA register RA2 a9 a8 a7 RA1 a6 a5 a4 a3 RA0 a2 a1 a0 a15 a14 a13 a12 a11 a10 15 Program memory space address 14 13 12 11 10 9 a9 8 a8 7 a7 6 a6 5 a5 4 a4 3 a3 2 a2 1 a1 0 a0 a15 a14 a13 a12 a11 a10 n Operand description * [RA] n Description example MOVLB [XY], [RA] ; The lower 8 bits of program memory address specified by RA are transferred to the data memory specified by CBR and XY registers, and to the next address in data memory 1 - 27 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture Program memory 3FFFH Data memory CBR + 15 12 11 RA3 RA2 RA1 RA0 87 43 0 CBR + X X Y Y +1 0000H [Note] The RA registers from 0F2F to 0F5H of SFR space and XY, HL, CBR and EBR registers from 0F9H to 0FEH should not be addressed as a transfer destination to data memory. If they are addressed, the contents of the addressed registers are undefined. 2.3.3.4 PC relative addressing mode The 8-bit address data in the instruction code is expanded to 16 bits, and the program branches to the address equal to that plus the address (PC value) for the next instruction. As a result, this type of addressing can specify a range of bytes from -128 to +127, centered on the next instruction. n Operand description * radr8 n Description example SJMP 35H ; Jumps to the address equal to the address for the next instuction plus 35H. 1 - 28 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture 2.3.3.5 PC based addressing mode The current address (PC value) is added to the content of the accumulator, and the program branches to that address plus one. Depending on the content of the accumulator, this gives 16 possible results. n Operand description * PC + A n Description example JMP PC+A ; Jumps to the address equal to the address for the next instruction (PC + 1) plus the accumulator content. 2.3.4 Addressing mode for external memory 2.3.4.1 RA register indirect addressing mode The external memory space address is indirectly specified by the 16-bit address data of the RA register. RA3 RA register RA2 a9 a8 a7 RA1 a6 a5 a4 a3 RA0 a2 a1 a0 a15 a14 a13 a12 a11 a10 15 External memory space address 14 13 12 11 10 9 a9 8 a8 7 a7 6 a6 5 a5 4 a4 3 a3 2 a2 1 a1 0 a0 a15 a14 a13 a12 a11 a10 n Operand description * [RA] n Description example MOVXB [HL], [RA] ; The content of the external memory specified by RA is transferred to the data memory specified by CBR and HL registers, and to the next address in data memory. [Note] The RA registers from 0F2F to 0F5H of SFR space and XY, HL, CBR, EBR registers from 0F9H to 0FEH should not be addressed as a transfer destination to data memory. If they are addressed, the contents of the addressed registers are undefined. 1 - 29 nX-4/250/300 Core Instruction Manual Chapter 1 Architecture External memory 0FFFFH Data memory CBR + 7 RA3 RA2 RA1 RA0 43 0 CBR + H H L L +1 0000H 2.3.4.2 Direct addressing mode The 16-bit address data is used to address all external memory space. n Operand description * xadr16 n Description example MOVXB [HL], 0FDCH; The content of external memory address 0FDCH is transferred to the data memory specified by CBR and HL registers, and to the next address in data memory. External memory 0FFFFH Data memory CBR + 7 0FDCH 43 0 CBR + H H L L +1 0000H [Note] The RA registers from 0F2F to 0F5H of SFR space and XY, HL, CBR and EBR registers from 0F9H to 0FEH should not be addressed as a transfer destination to data memory. If they are addressed, the contents of the addressed registers are undefined. 1 - 30 Chapter 2 INSTRUCTION SET This chapter presents details on the function of the nX-4/250 core and nX-4/300 core instructions. nX-4/250/300 Core Instruction Manual Chapter 2 Instruction set 1. OVERVIEW The nX-4/250 core and nX-4/300 core instruction codes are 16-bit length, and most instructions operate at one word per cycle. The nX/-4/250 core and nX/300 core have 440 kinds of instruction, and 450 kinds of instruction respectively. nX-4/250 nX-4/300 * Transfer instructions .............................................................. 38 types 38 types * Rotate instructions ................................................................. 20 types 20 types * Increment/decrement instructions ......................................... 20 types 20 types * Arithmetic operation instructions ........................................... 96 types 96 types * Comparison instructions ........................................................ 19 types 19 types * Logical operation instructions ............................................... 57 types 57 types * Mask operation instructions .................................................. 46 types 50 types * Bit operation instructions ....................................................... 36 types 40 types * ROM table reference instructions .......................................... 32 types 32 types * External memory transfer instructions ................................... 32 types 32 types * Stack operation instructions .................................................. 4 types 4 types * Flag operation instructions .................................................... 6 types 8 types * Branch instructions ................................................................ 4 types 4 types * Conditional branch instructions ............................................. 7 types 7 types * Call/return instructions ........................................................... 5 types 5 types * Control instructions ............................................................... 18 types 18 types These instructions can be classified by word length and machine cycle as shown below. * 1 word/1 machine cycle ......................................................... 369 types 379 types * 1 word/2 machine cycles ....................................................... 28 types 28 types * 1 word/3 machine cycles ....................................................... 8 types 8 types * 2 words/2 machine cycles ..................................................... 2 types 2 types * 2 words/3 machine cycles ..................................................... 33 types 33 types Instructions have the following functions: (1) Transfer instructions These instructions handle data memory transfer and immediate data transfer between accumulator and data memory. Rotate instructions These instructions rotate data memory left and right. Increment/decrement instructions These instructions handle data memory increment and decrement. Arithmetic operation instructions These instructions handle add and subtract operations for data memory and accumulator, or data memory and immediate data. Comparison instructions These instructions handle comparison between data memory and accumulator, or data memory and immediate data. Logical operation instructions These instructions handle logical product, logical add and exclusive OR between data (2) (3) (4) (5) (6) 2-1 nX-4/250/300 Core Instruction Manual Chapter 2 Instruction set (7) memory and accumulator, or data memory and immediate data. Mask operation instructions These instructions handle set, clear and transfer operations for non-masked data memory bits. Bit operation instructions These instructions handle set, clear and transfer operations for special data memory bits. ROM table reference instructions These instructions handle transfer of program memory table data to data memory. (8) (9) (10) External memory transfer instructions These instructions handle transfer of external memory data to data memory. (11) Stack operation instructions These instructions handle save of flag register, accumulator, HL registers, XY register, extra bank register and current bank register to the register stack, and restore operations. (12) Flag operation instructions These instructions handle set and clear operations for the zero flag, carry flag and G flag. (13) Branch instructions These instructions execute branches to program memory absolute and relative addresses. (14) Conditional branch instructions These instructions execute branches as per the contents of the zero flag, carry flag and G flag. (15) Call/return instructions These instructions execute subroutine call/return processing, and return from interrupt routines. (16) Control instructions These instructions set the current bank register, extra bank register, RA0 to RA3 registers, HL register, and XY register, as well as starting melody and halting the CPU. 2-2 nX-4/250/300 Core Instruction Manual Chapter 2 Instruction set 2. OPERAND EXPRESSION There are two types of instructions: those which have one or two operands, and those which have none. Operands are specified in the order of ,
We use cookies to deliver the best possible
web experience and assist with our advertising efforts. By continuing to use
this site, you consent to the use of cookies. For more information on
cookies, please take a look at our Privacy Policy.